<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><spring:message  code="pim"/> - <spring:message  code="manage.projects"/></title>
<link href="<%= request.getContextPath() %>/css/custom.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/v.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/paging.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/jquery.ui.dialog.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.6.2.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-ui-1.8.14.custom.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.hint.text.js"></script>
<%@include file="script/pim-util.jsp" %>
<%@include file="script/paging-script.jsp" %>
<%@include file="script/project-script.jsp" %>
<script type="text/javascript">
jQuery(document).ready(function(){    
    $('input[title]').inputHints();	
});   
</script>
</head>
<body>
<% try{ %>
<c:if test="${bean.isSigned == true }">
<div id="all">
<div id="wrapper">
<div id="mainheader">
	<jsp:include page="include/common/headerSignedIn.jsp" />
</div> 
<div id="content-wrapper">
<div id="top-menu">
     <jsp:include page="include/common/topMenuHome.jsp" />
</div>
<div class="pg-left-panel">
	   <jsp:include page="include/common/leftMenu.jsp" />
</div>
<div class="right-panel-application">
<spring:hasBindErrors name="projectQuery">
        <c:if test="${errors.errorCount > 0}" >
            <div class="alert">               
                 <ul>
                    <c:forEach var="error" items="${errors.allErrors}">
                       <li>
                          <spring:message code="${error.code}" text="${error.defaultMessage}"/>
                       </li>
                    </c:forEach>
                 </ul>
            </div>
        </c:if>
</spring:hasBindErrors>	
<div id="dialogDeleteProject"></div>
<form:form action="" method="post" commandName="projectQuery" name="frmProjects">
<div class="right-content">	
	<div style="margin-top:12px;">
	     <c:if test="${bean.isAdmin == true }"> 
	     <div class="v-row">
	       <div class="v-row-left" style="margin-left: 10px;">
	             <span><spring:message  code="project.status"/></span>			   
				 <form:select cssStyle="width:150px;margin-left: 10px; height: 24px;" path="statusId">
                        <option value="0"><spring:message code="all" /></option>
                        <c:forEach var="status" items="${bean.statuses}">
                         <option value="${status.statusid}"
                               <c:if test="${projectQuery.statusId == status.statusid}">selected="selected"</c:if>>
                               <c:out value="${status.name}" />
                         </option>
                        </c:forEach>
                </form:select>	
		   </div> 
		   <div class="v-row-right"> 	
	        <form:input maxlength="50" cssClass="new-manage-org-search txt-search"  path="searchKey" 
	          cssStyle="margin-right: 10px;" title="Keyword..."/>
	        <input type="button" class="bt-form" id="searchProjects" style="margin-right: 10px;"
				   value='<spring:message  code="search"/>'>
			</div>	   
	     </div>
		</c:if>
									
		<div><b style="margin-left: 10px;" 
		     class="v-title"><spring:message  code="listOfProjects"/></b>
		</div>	
		
		<div class="new-manage-org-dot-line"></div>
		
		<c:choose>
		<c:when test="${bean.countList == 0 && projectQuery.searchKey != ''}">
			<div class="new-manage-org-list-content" style="margin-right: 18px;">
				<span style="margin-left: 10px;"><spring:message  code="search.empty"/></span>
			</div>
		</c:when>
		
		<c:otherwise>
		<c:if test="${bean.isAdmin == true}">
			<div align="right" class="new-manage-org-action-head">
				<a class="new-manage-org-link" 
				   href="handleProject.htm?cmd=add"> + <spring:message  code="add.project"/></a>
				   &nbsp;|&nbsp;
				<a class="new-manage-org-link" onClick="deleteProjects()"
				   href="javascript:void(0);"><spring:message  code="delete.project"/></a>   
			</div>
		</c:if>
		
		<c:forEach var="project" items="${bean.projects }">
		
			<div class="new-manage-org-folder-news">
				<c:if test="${bean.isAdmin == true}">
					<div class="new-manage-org-checkOrg">										
					   <form:checkbox path="projectIds" value="${project.projectid}" cssClass="ckbChild"/>										
					</div>
				</c:if>
				
				<div class="new-manage-org-logo-org">
				<c:choose>
				 <c:when test="${bean.isAdmin == true}">
 				   <c:set value="members.htm?pnum=${project.number}&tab=listMembers" var="url"></c:set>  
				 </c:when>
				 <c:otherwise>
				   <c:set value="tasks.htm?pnum=${project.number}" var="url"></c:set>
				 </c:otherwise>
				</c:choose> 				     				     
					  <a href="${url}">
							<c:set value="${fn:trim(project.logourl)}" var="logo" />
							<c:choose>
							<c:when test="${logo == null || logo == ''}">
								<div class="logo" align="center">
									<img onLoad="scaleImg(this,150,120)" alt="" src="/pim/images/small_noImage.gif"/>
								</div>
							</c:when>
							<c:otherwise>
								<div class="logo" align="center">
									 <img alt="" src="${logo}" onLoad="scaleImg(this,150,120)"/>
								</div>
							</c:otherwise>
							</c:choose> 
					   </a>
				 </div>
				 
				 <div class="new-manage-org-content">
					
					<span class="new-manage-org-name"> 
					  <c:if test="${bean.isAdmin == true}">
						  <span class="v-bt-edit">
							  <a href="handleProject.htm?cmd=edit&pnum=<c:out value="${project.number}"></c:out>" 
							      class="v-link" ><spring:message code="button.edit" />
							   </a>
						  </span>
						  &nbsp;
		              </c:if>
					  <a class="new-manage-org-link" href="${url}">
					      <c:out value="${project.name}"></c:out>
					   </a>
					</span>
					
				 </div>
				 
				 <div style="padding-top: 10px;">
					<table style="clear: none;">
					<tr>
					<td style="padding-right: 10px;">
						<span><spring:message  code="project.number"/></span> 					
						<span>
						     <span> : </span> <c:out value="${project.number}"></c:out> 
						</span> 
					</td>
			        
			        <td style="padding-left: 10px;"> 
						<span><spring:message  code="project.customer"/></span> 
						<span>
						     <span> : </span> <c:out value="${project.customer.name }"></c:out>
						</span> 
					<td>				
					</tr>
					
					<tr>
					<td style="padding-right: 10px;">
						<span><spring:message  code="project.group"/></span> 
						<span>
						     <span> : </span>  <c:out value="${project.group.employee.visa }"></c:out> 
						</span>
					</td>
					
					<td  style="padding-left: 10px;">					
						<span><spring:message  code="project.status"/></span> 
						<span>
						     <span> : </span>  <c:out value="${project.projectStatus.name}"></c:out> 
						</span>
					</td>
					</tr>
					
					<tr>
					<td style="padding-right: 10px;">
						<span><spring:message  code="project.startdate"/></span> 
						<span>
						     <span> : </span>   <c:out value="${project.startdate}"></c:out>
						</span>
					</td>
					<td style="padding-left: 10px;">
						<span><spring:message  code="project.languages"/></span> 
						<span>
						     <span> : </span>   <c:out value="${project.languages}"></c:out>
						</span>
					</td>
					</tr>
					</table>
					
				</div> 
			</div>
			<br />
		</c:forEach>		
		</c:otherwise>		
		</c:choose>
	</div>
    </div>
    <c:if test="${bean.isAdmin == true && bean.total > bean.itemsPerPage}">  
    <div id="paging" class="productView-paging" style="width: 680px;float:right;padding-bottom:20px;">		
			<c:set value="${bean.paging}" var="paging"></c:set>
			<%@ include file="include/common/pagination.jsp"%>		
    </div>   
    </c:if> 
    <input type="hidden" name="currentURL" value="${bean.currentURL}"/>
    <input type="hidden" name="cmd"/>
    <input type="hidden" name="currentPage" value="${bean.currentPage}"/>
</form:form>
</div>	
</div>
</div>
<div class="footer">
	<jsp:include page="include/common/footer.jsp" />
</div>
</div>
</c:if>
<% } catch(RuntimeException re){ re.printStackTrace(); } %>
</body>
</html>